
//
//  UserModel.m
//  ZQLearn
//
//  Created by 朵 on 2019/4/22.
//  Copyright © 2019年 macfeel. All rights reserved.
//

#import "UserModel.h"
#import "NSDictionary+DeleteNull.h"
#import <MJExtension/MJExtension.h>
@implementation UserModel

+(instancetype)shareInstance{
    static UserModel *_userModel = nil;
    static dispatch_once_t t;
    dispatch_once(&t,^{
        _userModel = [[UserModel alloc]init];
    });
    return _userModel;
}

///防止后台返回的字段不对应或多或少    引起的crash
-(void)setValue:(id)value forUndefinedKey:(nonnull NSString *)key{
    
    
}


+(void)saveUserInfoWithDic:(NSDictionary *)dic{
    
    //    NSDictionary *dict = [dic deleteNull];
    
    [self saveData:dic];
    
}

+(void)cleanUserInfo{
    
//    [NUserModel shareInstance].userInfoId = nil;
//    [NUserModel shareInstance].userInfoName = nil;
//    [NUserModel shareInstance].userInfoCreateTime = nil;
//    [NUserModel shareInstance].userInfoSalt = nil;
//    [NUserModel shareInstance].userInfoStatus = nil;
//    [NUserModel shareInstance].userInfoNickname = nil;
//    [NUserModel shareInstance].userInfoUpdateTime = nil;
//    [NUserModel shareInstance].userInfoNamePwd = nil;
//    [NUserModel shareInstance].userInfoType = nil;
//    [NUserModel shareInstance].userInfoTel = nil;
//    [NUserModel shareInstance].userInfoCertificationStatus = nil;
//    [NUserModel shareInstance].userInfoCertificationType = nil;
//    [NUserModel shareInstance].userInfoLatestTime = nil;
    [self saveData:nil];
    
}

+ (void)saveData:(NSDictionary *)data{
    
    [[NSUserDefaults standardUserDefaults] setObject:[data deleteNull] forKey:kSaveUserInfoKey];
    YYLog(@"%@",[data deleteNull]);
    [[NSUserDefaults standardUserDefaults] synchronize];
    
}



@end
